<?php
/* @var $this SecurityIpController */

$this->breadcrumbs=array(
	'综合控制台'=>array($this->pre_module_url.'/index/index'),
	'子账号管理'=>array($this->pre_module_url.'/memSub/account'),
	'安全管理'=>array($this->pre_module_url.'/securityIp/admin'),
);
?>
<div class="security_manage">
	<div class="notice c_f">
		<span class="f_l tit">注意：</span>
		<p>1、设定的IP必须是外网IP而非内部IP，不建议ADSl拨号用户使用该功能。</p>
		<p>2、设置后，子账号将只能在被授权允许的IP地址登录"卖家中心"，其他IP登录将提示"未授权的IP"。</p>
	</div>
	<div class="set_ip">
		<?php $form=$this->beginWidget('CActiveForm', array(
			'id'=>'setting-form',
			'enableAjaxValidation'=>false,
		)); ?>
			<?php echo $form->hiddenField($model,'zkl_title')?>
			<?php echo $form->hiddenField($model,'zkl_variable')?>
			<ul class="form_list form_list2">
				<li class="c_f"><span class="tit fs_14">允许访问的IP：</span>
					<div class="cont f_l">
						<ul class="sub_li">
						<?php if(!empty($model->zkl_valued)){ foreach(unserialize($model->zkl_valued) as $key=>$val){?>
							<?php $ips = explode('.',$val)?>
							<li>
								<span class="ico ip"><?php echo CHtml::textField('ip['.$key.'][1]',$ips[0],array('class'=>'ip_ipt ipstep'))?></span>
								<span class="ico ip"><?php echo CHtml::textField('ip['.$key.'][2]',$ips[1],array('class'=>'ip_ipt ipstep'))?></span>
								<span class="ico ip"><?php echo CHtml::textField('ip['.$key.'][3]',$ips[2],array('class'=>'ip_ipt ipstep'))?></span>
								<span class="ip"><?php echo CHtml::textField('ip['.$key.'][4]',$ips[3],array('class'=>'ip_ipt ipstep'))?></span>
							</li>
						<?php }}else{?>
							<li>
								<span class="ico ip"><?php echo CHtml::textField('ip[0][1]','',array('class'=>'ip_ipt ipstep'))?></span>
								<span class="ico ip"><?php echo CHtml::textField('ip[0][2]','',array('class'=>'ip_ipt ipstep'))?></span>
								<span class="ico ip"><?php echo CHtml::textField('ip[0][3]','',array('class'=>'ip_ipt ipstep'))?></span>
								<span class="ip"><?php echo CHtml::textField('ip[0][4]','',array('class'=>'ip_ipt ipstep'))?></span>
							</li>
							<li>
								<span class="ico ip"><?php echo CHtml::textField('ip[1][1]','',array('class'=>'ip_ipt ipstep'))?></span>
								<span class="ico ip"><?php echo CHtml::textField('ip[1][2]','',array('class'=>'ip_ipt ipstep'))?></span>
								<span class="ico ip"><?php echo CHtml::textField('ip[1][3]','',array('class'=>'ip_ipt ipstep'))?></span>
								<span class="ip"><?php echo CHtml::textField('ip[1][4]','',array('class'=>'ip_ipt ipstep'))?></span>
							</li>
							<li>
								<span class="ico ip"><?php echo CHtml::textField('ip[2][1]','',array('class'=>'ip_ipt ipstep'))?></span>
								<span class="ico ip"><?php echo CHtml::textField('ip[2][2]','',array('class'=>'ip_ipt ipstep'))?></span>
								<span class="ico ip"><?php echo CHtml::textField('ip[2][3]','',array('class'=>'ip_ipt ipstep'))?></span>
								<span class="ip"><?php echo CHtml::textField('ip[2][4]','',array('class'=>'ip_ipt ipstep'))?></span>
							</li>	
						<?php }?>	
							<li class="no_border"><a class="c_06c addItem" href="javascript:" title="">新增允许访问IP</a></li>
						</ul>
					</div>
				</li>
				<li class="c_f"><span class="tit">&nbsp;</span>
					<div class="cont f_l">
						<?php echo CHtml::submitButton(Yii::t('adm','Save Data'),array('class'=>'mem_btn mem_btn20 mr5'))?>
						<?php echo CHtml::resetButton(Yii::t('adm','Reset'),array('class'=>'mem_btn mem_btn07'))?>
					</div>
				</li>
			</ul>
		<?php $this->endWidget(); ?>
	</div>
</div>                  	    	            

<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">

var n = <?php echo isset($key)?$key+1:3;?>
		
$('.addItem').bind('click',function(){
	var str = '<li><span class="ico ip"><input class="ip_ipt ipstep" type="text" value="" name="ip['+n+'][1]" /></span><span class="ico ip"><input class="ip_ipt ipstep" type="text" value="" name="ip['+n+'][2]" /></span><span class="ico ip"><input class="ip_ipt ipstep" type="text" value="" name="ip['+n+'][3]" /></span><span class="ip"><input class="ip_ipt ipstep" type="text" value="" name="ip['+n+'][4]" /></span></li>'
	$(this).parent().before(str);
});
$('.ipstep').live('keydown',function(){
	//退格键
	if(event.keyCode==8){
		return;
	}
	//点号
	if(event.keyCode==110){
		this.blur();
		$(this).parent().next('span').find('.ipstep').focus();
	}
	//大于三位数
	if($(this).val().length==3){
		this.blur();
		$(this).parent().next('span').find('.ipstep').focus();
	}
})
$('.ipstep').live('keyup',function(){
	if(event.keyCode==110){
		$(this).val('');
	}
})
</script>



